|
SystemMetrics Capion,Menuなどの高さなどシステム状態を知りたくつくりました、下図は実行時画像でテキストボックスにSM_CXSCREEN などの表示してみました。 右はソースです MicroSoftにSystemMetricsの詳細が載っておりました ![]() |
using System.Runtime.InteropServices;
namespace systemmatrics
{
public partial class Form1 : Form
{
[DllImport("user32.dll")] public static extern int GetSystemMetrics(int nIndex);
public const int SM_CXSCREEN = 0; // Screen width
public const int SM_CYSCREEN = 1; // Screen height
public const int SM_CYMENU = 15; //
public const int SM_CYCAPTION = 4; //
public const int SM_CYHSCROLL = 3; // 水平スクロ−バ−の高さ
public const int SM_CXVSCROLL = 2; // 垂直スクロ−ルバ−の幅
public const int SM_CXFRAME = 32; // 水平罫線の幅
int screenWidth;
int screenHeight;
int Caption;
int Menu,VScroll,HScroll,CXFrame;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
{
screenWidth = GetSystemMetrics(SM_CXSCREEN);
screenHeight = GetSystemMetrics(SM_CYSCREEN);
Caption= GetSystemMetrics(SM_CYCAPTION);
Menu = GetSystemMetrics(SM_CYMENU);
VScroll= GetSystemMetrics(SM_CXVSCROLL);
HScroll= GetSystemMetrics(SM_CYHSCROLL);
CXFrame = GetSystemMetrics(SM_CXFRAME);
textBox1.AppendText("ScreenWidth=" + screenWidth.ToString() + " Dot \r\n");
textBox1.AppendText("ScreenHeight=" + screenHeight.ToString() + " Dot \r\n");
textBox1.AppendText("CYCAPTION="+Caption.ToString()+ " Dot \r\n");
textBox1.AppendText("CYMENU="+Menu.ToString()+ " Dot \r\n");
textBox1.AppendText("CXVScroll=" + VScroll.ToString() + " Dot \r\n");
textBox1.AppendText("CXHScroll=" + HScroll.ToString() + " Dot \r\n");
textBox1.AppendText("CXFrame=" + CXFrame.ToString() + " Dot \r\n");
}
}
}
}
|